﻿using System.Data;
using System.Data.SqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



    namespace 学生成绩查询及选课系统
    {
        class Conndb
        {
            //public static string ser = "127.0.0.1";
            //public static string db = "test";
            //public static string uid = "sa";
            //public static string pwd = "lzc1091550688";
            //public static string strconn = "server=" + ser + ";" + "database=" + db + ";" + "uid=" + uid + ";" + "pwd=" + pwd;
            public static SqlConnection conn = null;
            public static string strconn = System.Configuration.ConfigurationManager.ConnectionStrings["sql"].ToString();


            /// <summary>
            /// 建立数据库连接
            /// </summary>
            /// <returns></returns>
            public static SqlConnection getconn()
            {
                conn = new SqlConnection(strconn);
                conn.Open();
                return conn;
            }

            /// <summary>
            /// 关闭数据库
            /// </summary>
            public static void closeconn()
            {
                conn.Close();   //关闭数据库的连接
                conn.Dispose();
            }
        }
    }
    

